package com.atguigu.day16.math01;

import org.junit.Test;

import java.util.Random;

/*
Random: 随机数类
       随机的小数
       随机整数
       随机的boolean值
 */
public class RandomTest {
    @Test
    public void test01() {
        Random random = new Random();

        for (int i = 0; i < 20; i++) {
            //[0,1)
            double v = random.nextDouble();
            System.out.println("v = " + v);
        }


    }

    @Test
    public void test02() {
        Random random = new Random();

        for (int i = 0; i < 50; i++) {
            //int num = random.nextInt();
            //[0,范围);
            int num = random.nextInt(10);
            System.out.println("num = " + num);

        }
    }
    @Test
    public void test03(){
        Random random = new Random(1);
        for (int i = 0; i < 10; i++) {
            boolean b = random.nextBoolean();
            System.out.print(b+" ");
        }
    }
    @Test
    public void test04(){
        Random random = new Random(1);

        for (int i = 0; i < 10; i++) {
            boolean b = random.nextBoolean();
            System.out.print(b+" ");
        }
    }
}
